<!DOCTYPE html>
<html lang="zn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>转换为Boolean</title>
    <script>
        /*
            将其他的数据类型转化为Boolean
                -使用Boolean()函数
                    -数字 -->布尔
                        -除了0和NaN，其余的都是true
                    
                    -字符串-->布尔
                        -除了空串，其余的都是true

                    null和undefined都会转换为false

                    对象也会转换为true
        */

        var a = 123;
        a = -123;
        a = 0;//false
        a = Infinity;//true
        a = NaN;//false

        a = Boolean(a);

        a ='';//false
        a = '   '
        a = 'sa'
        a = Boolean(a);

        a = null;//false
        a = Boolean(a);

        a = undefined;//false
        a = Boolean(a);

        console.log(typeof a);
        console.log(a);
    </script>
</head>
<body>
    
</body>
</html>